﻿using AmazonServices.Amazon;
using System.ServiceModel;
using Simple;

namespace AmazonServices
{
   
    /// <summary>
    /// Common Amazon service functionality
    /// </summary>
    public static class AmazonService
    {
        // your Amazon ID's
        private const string AccessKeyId = Keys.AccessKeyId;
        private const string SecretKey = Keys.SecretKey;

        /// <summary>
        /// Creates a commerce service client
        /// </summary>
        /// <returns></returns>
        public static AWSECommerceServicePortTypeClient Create()
        {
            // Create a WCF Amazon ECS client
            BasicHttpBinding binding = new BasicHttpBinding(BasicHttpSecurityMode.Transport);
            binding.MaxReceivedMessageSize = int.MaxValue;
            AWSECommerceServicePortTypeClient client = new AWSECommerceServicePortTypeClient(
                binding,
                new EndpointAddress("https://webservices.amazon.com/onca/soap?Service=AWSECommerceService"));

            // Add authentication to the ECS client
            client.ChannelFactory.Endpoint.Behaviors.Add(new AmazonSigningEndpointBehavior(AccessKeyId, SecretKey));

            return client;
        }
    }
}
